/***************************init***************/

function queryTaskOwn_taskOwn(page){
	sys_loading();
	var parm = $('#queryTaskOwnForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('myTask-query');
	sys_record_parm('myTask',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#taskOwnResultList').html(result);
		}
	});
}


function edit_taskOwn(code) {
	var parm = {'code':code};
	var url = create_url('myTask-edit');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm});
}

function deleteTaskOwn_taskOwn(code, title) {
	var url = create_url('myTask-delete');
		$.Zebra_Dialog('要删除 《' + title + '》 任务吗?',{
			'type': 'question',
			'title': '警告' ,
			'buttons':[
		           {caption:'确认',callback:function() {
		        	   aidExecuteTaskOwn_taskOwn(code, url);
		    		}},
		           {caption:'取消',callback:function(){}
		    	}]
	});
}

function aidExecuteTaskOwn_taskOwn(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				new $.Zebra_Dialog('删除成功', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
				queryTaskOwn_taskOwn();
			} else if ('deleted' == result){ 
				new $.Zebra_Dialog('你不能删除指派的任务', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
			} else {
				new $.Zebra_Dialog('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!', {
				    'buttons':  false,
				    'modal': false,
				    'auto_close': 2000
				});
			}
		}
	});
}

/*******************************edit***********************/
function saveTaskOwn_taskOwn() {
	var parm = $('#editTaskOwnForm').serialize();
	var url = create_url('myTask-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_msg('操作成功');
				sys_load_handle('myTask');
			}else if(result == 'not_find') {
				sys_msg('请填写内容', '警告');
			}else if(result == 'null_title') {
				sys_msg('请填写标题', '警告');
			}else if(result == 'null_time') {
				sys_msg('任务时间不能为空', '警告');
			}else {
				sys_msg('操作失败', '警告');
			}
		}
	});
}
